package syyrjx.controller;

import syyrjx.jdbc.QuestionDB;
import syyrjx.jdbc.util.JDBCTool;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class ShowQuestionServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.show(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.show(request, response);
    }
    private void show(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        QuestionDB qdb = new QuestionDB();
        Map<Integer,Map<String,Object>> queInfo = qdb.show();

        request.setAttribute("queInfo",queInfo);
        request.setAttribute("queCount", JDBCTool.queCount);
        request.getRequestDispatcher("/queShow.jsp").forward(request,response);
    }
}
